// pages/book/list/index.js
import { BookModel } from '../../../models/book.js'
import { random } from '../../../utils/common.js'

const bookModel = new BookModel()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    books: [],
    searching: false,
    more: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: async function (options) {
      const books = await bookModel.getHotList()
      this.setData({ books })
   
  },

  onSearching: function(evt) {
    this.setData({searching: true})
  },

  onCancel: function(evt) {
    this.setData({searching: false})
  },

  onReachBottom: function(){
    this.setData({ more: random(16)})
  }
})